﻿#if UNITY_EDITOR

using UnityEditor;
using UnityEngine;

namespace AI.Graph.Editor {


    [CustomEditor (typeof (Condition), true)]
    public class ConditionView : CollapsibleNodeView<Condition> {

        protected sealed override Vector2 OnDrawNode (bool drawSimple) {
            if (drawSimple) {
                Rect nodeRect = DrawNodeHeader (0);

                nodeRect = DrawNodePortArea (nodeRect.yMax, new[] {node.input}, new[] {node.outputTrue, node.outputFalse});

                nodeRect = DrawNodeFooter (nodeRect.yMax);

                return new Vector2 (180, nodeRect.yMax);
            }
            else {
                Rect nodeRect = DrawNodeHeaderWithToggle (0, ref node.isCollapsed);

                nodeRect = DrawNodePortArea (nodeRect.yMax, new[] {node.input}, new[] {node.outputTrue, node.outputFalse});

                nodeRect = DrawNodeCollapseArea (nodeRect.yMax);

                nodeRect = DrawNodeFooter (nodeRect.yMax);

                return new Vector2 (300, nodeRect.yMax);
            }
        }

    }


}
#endif